/*
* VFilter.h: 2008-3-31**
* Define a virtual class Filter to do optimization on VBlock, Many
* filters can be implemented to do appropriate optimizations. **
* xxxFilter can do xxx on VBlock**
* By: CrossBit Group, vivy**
*/

#ifndef VFILTER_H
#define VFILTER_H

#include "crossbit/common.h"

namespace crossbit{

    class VBlock;
    
    class VFilter{
    
        public:
            virtual ~VFilter();
            
            virtual XTUint32 run(VBlock *vb) = 0;
    };
    
    //=============================================================
    //Definition of various VFilters
    //=============================================================
    
    //PrintFilter: print vinsts in VBlock
    class PrintFilter : public VFilter{
        
        public: 
            XTUint32 run(VBlock *);
    };
    
    //SSAFormFilter: SSA form for VBlock
    class SSAFormFilter : public VFilter{
      
        public: 
            XTUint32 run(VBlock *);
    };
    
    //RedundancyEliminateFilter: Eliminate redundancy for VBlock
    class RedundancyEliminateFilter : public VFilter{
     
         public: 
            XTUint32 run(VBlock *);
    };
    
    //CollectNextUseInfoFilter: collect V_registers next use information for register allocation 
    class CollectNextUseInfoFilter : public VFilter{
      
          public: 
             XTUint32 run(VBlock *);
              
          private: 
              const static XTInt32 UNMAPPED = 0x01;
              const static XTInt32 MAPPED = 0x02;
              const static XTInt32 SPILLED = 0x04;
           
              struct RegUsage{
              XTInt32 status;
              XTRegNum map;
              XTInt32 inst;
              };
    };
    
}

#endif

